<template>
  <div class="app-container">
    <div class="filter-container">
      <div class="filter-item">
        <div class="searchItem">
          <span class="searchLabel">对账日期：</span>
          <DatePicker :mode="1" :startDate.sync="listQuery.acDate$gte" :endDate.sync="listQuery.acDate$lte" clearable />
        </div>
      </div>
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
        查询
      </el-button>
    </div>
    <el-table ref="table" v-loading="listLoading" :data="list" border fit highlight-current-row row-key="id" style="width: 100%;" :max-height="tableHeight">
      <el-table-column label="序号" type="index" align="center"/>
      <el-table-column label="对账日期" prop="acDate" align="center" />
      <el-table-column label="订单号" prop="zcgjOrderIdentifier" align="center" />
      <!-- <el-table-column label="支付方式" align="center">
        <template slot-scope="{row}">
          {{ row.payMethod | typeFilter }}
        </template>
      </el-table-column> -->
      <el-table-column label="业务种类" align="center">
        <template slot-scope="{row}">
          {{ row.txCode | payFilter }}
        </template>
      </el-table-column>
      <el-table-column label="交易金额" prop="trxAmount" align="center">
        <template slot-scope="{row}">
          <div style="color: red" v-if="row.txCode == '01'">{{"-" + row.trxAmount}}</div>
          <div v-else>{{row.trxAmount}}</div>
        </template>
      </el-table-column>
      <el-table-column label="平台费用" prop="merSerFee" align="center" />
      <el-table-column label="银行手续费" prop="subMerFee" align="center">
        <template slot-scope="{row}">
          <div>{{row.subMerFee - row.merSerFee }}</div>
        </template>
      </el-table-column>
      <el-table-column label="交易流水号" prop="serialNo" align="center" />
    </el-table>
    <Pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNo" :limit.sync="listQuery.pageSize"
      @pagination="getList" />
  </div>
</template>

<script>
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination'
import DatePicker from '@/components/DatePicker'
import { b2cBillPageByQo } from '@/api/bank'
import updateTableMixin from '@/mixin/updateTable'

export default {
  name: 'xcxBill',
  directives: { waves },
  props: {},
  components: {
    Pagination,
    DatePicker
  },
  filters: {
    typeFilter(status) {
      const statusMap = {
        '01': '工银e支付',
        '02': '微信支付',
        '03': '支付宝',
        '04': '预付卡',
        '05': '转账',
        '06': '二维码主扫支付',
        '07': 'POS支付',
        '08': 'e支付有协议小额免密',
        '09': '微信线下支付',
        '10': '会员卡小额免密',
        '11': '支付宝线下支付',
        '12': '二维码被扫支付',
        '13': '合作方钱包支付',
        '14': '车牌付',
        '15': '全额兑付',
        '16': '融资支付',
        '17': '云闪付支付',
        '18': '数字人民币',
        '99': '其他',
      }
      return statusMap[status]
    },
    payFilter(status) {
      const statusMap = {
        '01': '退款',
        '02': '收款',
        '04': '充值',
        '12': '预付卡充值退款'
      }
      return statusMap[status]
    }
  },
  mixins: [updateTableMixin],
  data() {
    return {
      list: [],
      total: 0,
      listLoading: false,
      listQuery: {
        acDate$gte: '',
        acDate$lte: '',
        pageNo: 1,
        pageSize: 20
      },
    }
  },
  computed: {},
  watch: {},
  methods: {
    getList() {
      this.listLoading = true
      b2cBillPageByQo(this.listQuery).then(response => {
        this.list = response.list || []
        this.total = response.totalCount
        this.listLoading = false
        this.updateTableHeight()
      }).catch(error => {
        console.log(error);
        this.listLoading = false
      })
    },
    handleFilter() {
      this.listQuery.pageNo = 1
      this.getList()
    },
  },
  created() {
    this.getList()
  },
  mounted() {
    
  },
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {},
}
</script>

<style lang='scss' scoped>
  .searchItem {
    display: flex;
    align-items: center;
    .searchLabel {
      color: #666;
    }
  }
</style>